/**
 * @license
 * Copyright Alibaba.com All Rights Reserved.
 *
 * Use of this source code is governed by an MIT-style license that can be
 * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
 */

import { InjectionToken, TemplateRef, Type } from '@angular/core';

import { ApesAlignType, ApesShapeSCType, ApesSizeDSType, ApesSizeLDSType, ApesSizeMDSType } from '../types';

import { BreakpointMap, ApesBreakpoint } from '../responsive/public-api';

// TODO: generate config files if custom build can be used.

export interface ApesConfig {
  affix?: AffixConfig;
  alert?: AlertConfig;
  anchor?: AnchorConfig;
  avatar?: AvatarConfig;
  backTop?: BackTopConfig;
  badge?: BadgeConfig;
  button?: ButtonConfig;
  card?: CardConfig;
  carousel?: CarouselConfig;
  cascader?: CascaderConfig;
  collapse?: CollapseConfig;
  collapsePanel?: CollapsePanelConfig;
  descriptions?: DescriptionsConfig;
  drawer?: DrawerConfig;
  empty?: EmptyConfig;
  form?: FormConfig;
  grid?: GridConfig;
  icon?: IconConfig;
  message?: MessageConfig;
  modal?: ModalConfig;
  notification?: NotificationConfig;
  progress?: ProgressConfig;
  rate?: RateConfig;
  spin?: SpinConfig;
  switch?: SwitchConfig;
  table?: TableConfig;
  tabs?: TabsConfig;
  timePicker?: TimePickerConfig;
  tree?: TreeConfig;
  treeSelect?: TreeSelectConfig;
  typography?: TypographyConfig;
}

export interface AffixConfig {
  apesOffsetBottom?: number;
  apesOffsetTop?: number;
}

export interface AlertConfig {
  apesCloseable?: boolean;
  apesShowIcon?: boolean;
}

export interface AvatarConfig {
  apesShape?: ApesShapeSCType;
  apesSize?: ApesSizeLDSType | number;
}

export interface AnchorConfig {
  apesBounds?: number;
  apesOffsetBottom?: number;
  apesOffsetTop?: number;
  apesShowInkInFixed?: boolean;
}

export interface BackTopConfig {
  apesVisibilityHeight?: number;
}

export interface BadgeConfig {
  apesColor?: number;
  apesOverflowCount?: number;
  apesShowZero?: number;
}

export interface ButtonConfig {
  apesSize?: 'large' | 'default' | 'small';
}

export interface CardConfig {
  apesSize?: ApesSizeDSType;
  apesHoverable?: boolean;
  apesBordered?: boolean;
}

export interface CarouselConfig {
  apesAutoPlay?: boolean;
  apesAutoPlaySpeed?: boolean;
  apesDots?: boolean;
  apesEffect?: 'scrollx' | 'fade' | string;
  apesEnableSwipe?: boolean;
  apesVertical?: boolean;
}

export interface CascaderConfig {
  apesSize?: string;
}

export interface CollapseConfig {
  apesAccordion?: boolean;
  apesBordered?: boolean;
}

export interface CollapsePanelConfig {
  apesShowArrow?: boolean;
}

export interface DescriptionsConfig {
  apesBorder?: boolean;
  apesColumn?: { [key in ApesBreakpoint]?: number } | number;
  apesSize?: 'default' | 'middle' | 'small';
  apesColon?: boolean;
}

export interface DrawerConfig {
  apesMask?: boolean;
  apesMaskClosable?: boolean;
}

export interface EmptyConfig {
  // tslint:disable-next-line no-any
  apesDefaultEmptyContent?: Type<any> | TemplateRef<string> | string | undefined;
}

export interface FormConfig {
  apesNoColon?: boolean;
}

export interface GridConfig {
  apesAlign?: ApesAlignType;
  apesGutter?: number | BreakpointMap;
  apesJustify?: 'start' | 'end' | 'center' | 'space-around' | 'space-between';
  apesType?: 'flex';
}

export interface IconConfig {
  apesTheme?: 'fill' | 'outline' | 'twotone';
  apesTwotoneColor?: string;
}

export interface MessageConfig {
  apesAnimate?: boolean;
  apesDuration?: number;
  apesMaxStack?: number;
  apesPauseOnHover?: boolean;
  apesTop?: number | string;
}

export interface ModalConfig {
  apesMask?: boolean;
  apesMaskClosable?: boolean;
}

export interface NotificationConfig extends MessageConfig {
  apesTop?: string | number;
  apesBottom?: string | number;
  apesPlacement?: 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight' | string;
}

export interface ProgressConfig {
  apesGapDegree?: number;
  apesGapPosition?: 'top' | 'right' | 'bottom' | 'left';
  apesShowInfo?: boolean;
  apesStrokeSwitch?: number;
  apesStrokeWidth?: number;
  apesSize?: 'default' | 'small';
  apesStrokeLinecap?: 'round' | 'square';
  apesStrokeColor?: string;
}

export interface RateConfig {
  apesAllowClear?: boolean;
  apesAllowHalf?: boolean;
}

export interface SpinConfig {
  apesIndicator?: TemplateRef<void>;
}

export interface SwitchConfig {
  apesSize: ApesSizeDSType;
}

export interface TableConfig {
  apesBordered?: boolean;
  apesSize?: ApesSizeMDSType;
  apesShowQuickJumper?: boolean;
  apesShowSizeChanger?: boolean;
  apesSimple?: boolean;
  apesHideOnSinglePage?: boolean;
}

export interface TabsConfig {
  apesAnimated?:
    | boolean
    | {
        inkBar: boolean;
        tabPane: boolean;
      };
  apesSize?: ApesSizeLDSType;
  apesType?: 'line' | 'card';
  apesTabBarGutter?: number;
  apesShowPagination?: boolean;
}

export interface TimePickerConfig {
  apesAllowEmpty?: boolean;
  apesClearText?: string;
  apesFormat?: string;
  apesHourStep?: number;
  apesMinuteStep?: number;
  apesSecondStep?: number;
  apesPopupClassName?: string;
  apesUse12Hours?: string;
}

export interface TreeConfig {
  apesBlockNode?: boolean;
  apesShowIcon?: boolean;
  apesHideUnMatched?: boolean;
}

export interface TreeSelectConfig {
  apesShowIcon?: string;
  apesShowLine?: boolean;
  apesDropdownMatchSelectWidth?: boolean;
  apesHideUnMatched?: boolean;
  apesSize?: 'large' | 'small' | 'default';
}

export interface TypographyConfig {
  apesEllipsisRows?: number;
}

export type ApesConfigKey = keyof ApesConfig;

/**
 * User should provide an object implements this interface to set global configurations.
 */
export const APES_CONFIG = new InjectionToken<ApesConfig>('apes-config');
